﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Dimok.Web.UI;

public partial class Controls_USIX_Bridge_Note : System.Web.UI.UserControl,IScriptControl {
	ScriptManager sm;
	public string OnLoaded { get; set; }
	public string OnInserted { get; set; }
	protected void Page_Load(object sender, EventArgs e) { }


	#region Ajax registration
	protected override void OnPreRender(EventArgs e) {
		if (!this.DesignMode) {
			sm = ScriptManager.GetCurrent(Page);
			if (sm == null) throw new HttpException("A ScriptManager control must exist on the current page.");
			sm.RegisterScriptControl(this);
		}
		fsNewNote.AppendStyle(Attributes);
		divNewNote.AppendStyle(Attributes);
		base.OnPreRender(e);
	}
	protected override void Render(HtmlTextWriter writer) {
		if (!this.DesignMode) sm.RegisterScriptDescriptors(this);
		base.Render(writer);
	}
	#endregion

	#region IScriptControl Members

	public IEnumerable<ScriptDescriptor> GetScriptDescriptors() {
		ScriptControlDescriptor descriptor = new ScriptControlDescriptor("motobankcorp.Bridge_Note", fsNewNote.ClientID);
		descriptor.AddProperty("selNoteTypesID", selNoteType.ClientID);
		descriptor.AddProperty("selNoteActionsID", selActionCode.ClientID);
		descriptor.AddProperty("selStatusesID", selStatus.ClientID);
		if (OnLoaded + "" != "") descriptor.AddEvent("loaded", OnLoaded);
		if (OnInserted + "" != "") descriptor.AddEvent("inserted", OnInserted);
		yield return descriptor;
	}

	public IEnumerable<ScriptReference> GetScriptReferences() {
		yield return new ScriptReference(System.IO.Path.ChangeExtension(AppRelativeVirtualPath, "js"));
	}

	#endregion

	#region IScriptControl Members

	IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors() {
		return GetScriptDescriptors();
	}

	IEnumerable<ScriptReference> IScriptControl.GetScriptReferences() {
		return GetScriptReferences();
	}

	#endregion
}
